
local ClientOHOH = _G.ClientOHOH;
local M = ClientOHOH.class.new(script, ClientOHOH.files.BaseComponent());
local Client_AudioManager = ClientOHOH.load.Client_AudioManager();

function M.new(self,...)
	return M(self,...);
end;

function M.ctor(self, parent)
	M.super.ctor(self, parent);
	self.bgm_list = {"bgm1","bgm2", "bgm3","bgm4","bgm6"};
	self:StartPlayBGM()
end;

function M.dtor(self)
	M.super.dtor(self);
end;


function M.RandomBGM(self)
	return self.bgm_list[ClientOHOH:Random(1, #self.bgm_list)];
end;


function M.PlayBGM(self)
	if not self.now_bgm then
		self.now_bgm = Client_AudioManager:PlayGloble(self:RandomBGM());
		return;
	end;
	if self.now_bgm and not self.now_bgm.IsPlaying then
		self.now_bgm:Stop();
		self.now_bgm = nil;
	end;
end;

function M.StartPlayBGM(self)
	if self.__updata_play_bgm then
		return;
	end;
	self.__updata_play_bgm = self:AddRenderUpdate("render", self.PlayBGM);
end;

function M.StopPlayBGM(self)
	if self.__updata_play_bgm then
		self.__updata_play_bgm:Disconnect();
		self.__updata_play_bgm = nil;
	end;
end;

return M